package com.gitee.fanx.notes.controller;

import com.gitee.fanx.notes.entity.Notes;
import com.gitee.fanx.notes.service.NotesService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author fanx
 */
@RestController
@RequestMapping("/notes")
public class NotesController {

	@Autowired
	private NotesService notesService;

	@PostMapping
	public void save(@RequestBody Notes notes) {
		notesService.save(notes);
	}

	@GetMapping
	public List<Notes> getAll() {
		return notesService.getAll();
	}

	@DeleteMapping(path = "/{id}")
	public void delete(@PathVariable("id") Long id) {
		notesService.deleteById(id);
	}

}
